package com.battery.controller;

import com.battery.pojo.PowerBank;
import com.battery.service.Power_BankService;
import com.battery.util.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(tags = "电源管理相关接口")
@RequestMapping("/powerbank")
public class Power_BankController {
    private Power_BankService power_bankService;
    @PostMapping("/addPowerBank")
    @ResponseBody
    @ApiOperation("添加电源")
    public Result addRule(@RequestBody @ApiParam(name="电源对象",value="传入json格式",required=true) PowerBank powerbank){
        Result result = power_bankService.addPowerBank(powerbank);
        return Result.ok().data("data",result);
    }
    @DeleteMapping("/deletePowerBank/{pb_id}")
    @ResponseBody
    @ApiOperation("删除电源")
    public Result deleteRule(@ApiParam(name="电源id",required=true) int pb_id){
        Result result = power_bankService.deletePowerBank(pb_id);
        return Result.ok().data("data",result);
    }
    @PutMapping("/updatePowerBank")
    @ResponseBody
    @ApiOperation("更新电源")
    public Result updatePowerBank(@RequestBody @ApiParam(name="电源id",required=true) PowerBank powerbank){
        Result result = power_bankService.updatePowerBank(powerbank);
        return Result.ok().data("data",result);
    }
    @PostMapping("/findPowerBank/{pb_id}")
    @ResponseBody
    @ApiOperation("查询电源")
    public Result findPowerBank(@RequestBody @ApiParam(name="电源id",required=true) int pb_id){
        Result result = power_bankService.findPowerBank(pb_id);
        return Result.ok().data("data",result);
    }
}
